/*
This file is part of Cafca.

Cafca is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cafca is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Cafca.  If not, see <http://www.gnu.org/licenses/>.

If you have any comment, suggestion or idea, do not hesitate to contact me at shenrotin@gmail.com
*/

package org.crag.cafca.gui;

import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.log4j.Logger;
import org.crag.cafca.db.XmlConnector;
import org.xml.sax.SAXException;


public class MenuManager 
{	
	/**
	 * Logger log4j. See log4j doc for more information.
	 */
	private static Logger log=Logger.getLogger(new Throwable().getStackTrace()[0].getClassName());
		
	private static MenuManager singleton;
	
	private Menu menu;
	
	public static MenuManager getMenuManager()
	{
		if (singleton==null)
		{
			MenuManager.singleton=new MenuManager();
		}
		
		return singleton;
	}

	public Menu getMenu()
	{
		return menu;
	}
	
	public void loadMenuFromXml(String xmlFile)
	{
		try 
		{
			XmlConnector xmlConnector=new XmlConnector(xmlFile);
			menu=xmlConnector.loadMenu();
			xmlConnector.close();
		} 
		catch (FileNotFoundException e)  
		{
			e.printStackTrace();
		} 
		catch (SAXException e) 
		{
			e.printStackTrace();
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}
}
